package priv.pront.code.robot.roboCom_pri_2021.zhi;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @Description:
 * @Author: pront
 * @Time:2023-07-09 16:42
 */
public class 字母串 {
    static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    static int n;

    public static void main(String[] args) throws IOException {
        n = Integer.parseInt(bf.readLine());
        for (int i = 0; i < n; i++) {
            String s = bf.readLine();
            boolean flag = false;
            char[] chs = s.toCharArray();
            for (int j = 1; j < chs.length; j++) {
                char pre = chs[j - 1];
                if (pre >= 65 && pre < 97) {
                    if (pre + 1 <= 90) {
                        if (pre + 1 != chs[j] && pre + 32 != chs[j]) {
                            System.out.println("N");
                            flag = true;
                            break;
                        }
                    } else {
                        if (pre + 32 != chs[j]) {
                            System.out.println("N");
                            flag = true;
                            break;
                        }
                    }
                } else if (pre >= 97 && pre <= 122) {
                    if (pre - 1 >= 97) {
                        if (pre - 1 != chs[j] && pre - 32 != chs[j]) {
                            System.out.println("N");
                            flag = true;
                            break;
                        }
                    } else {
                        if (pre - 32 != chs[j]) {
                            System.out.println("N");
                            flag = true;
                            break;
                        }
                    }
                }

            }
            if (!flag) System.out.println("Y");
        }

    }
}
